IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Parameter]') AND type in (N'U'))
BEGIN
     DROP TABLE [dbo].[Parameter]
END
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Parameter](
     [ParameterId]           [int]          NOT NULL,
     [ParameterCd]           [varchar](30)  NOT NULL,
     [ParameterName]         [varchar](128) NOT NULL,
     [ParameterDefaultValue] [varchar](256)     NULL,
     [ParamAllowMutliFlag]   [tinyint]      NOT NULL CONSTRAINT [DF_Parameter_ParamAllowMutliFlag]  DEFAULT ((0)),
     [ParamMaxMultiCnt]      [int]          NOT NULL CONSTRAINT [DF_Parameter_ParamMaxMutliFlag]  DEFAULT ((0)),
     [LastModDt]             [datetime]     NOT NULL CONSTRAINT [DF_Parameter_LastModDt] DEFAULT (getdate()),
     CONSTRAINT [PK_Parameter] PRIMARY KEY CLUSTERED ( [ParameterId] ASC )
) ON [PRIMARY]
GO

SET ANSI_PADDING OFF
GO

CREATE UNIQUE NONCLUSTERED INDEX [IX_Parameter_Code] ON [dbo].[Parameter] 
     ( [ParameterCd] ASC ) ON [Data_Index]
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Unique Identifier of a particular Parameter.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Parameter', @level2type=N'COLUMN',@level2name=N'ParameterId'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Secondary Unique Identifier of a particular Parameter, user defined.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Parameter', @level2type=N'COLUMN',@level2name=N'ParameterCd'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'User-friendly name of parameter.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Parameter', @level2type=N'COLUMN',@level2name=N'ParameterName'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Default value of parameter when added to EAV table.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Parameter', @level2type=N'COLUMN',@level2name=N'ParameterDefaultValue'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Flag indicating whether multiple records of this parameter type are allowed, also defines whether to look in the EAV or EAVMulti table for the parameter.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Parameter', @level2type=N'COLUMN',@level2name=N'ParamAllowMutliFlag'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Maximum number of multiple records if allowed.  If not allowed then this value is ignored, zero indicates no limit.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Parameter', @level2type=N'COLUMN',@level2name=N'ParamMaxMultiCnt'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'The last date/time the record was changed.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Parameter', @level2type=N'COLUMN',@level2name=N'LastModDt'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Parameters.  Contains master parameter list and basic parameter control data.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Parameter'
GO
